import React from 'react';
import { Rate } from 'antd';

/**
 * 收藏组件
 *
 *
 * 获取 Rate 的 interface
 * React.ComponentProps<typeof Rate>
 *
 */
interface PinProps extends React.ComponentProps<typeof Rate> {
  checked: boolean;
  onCheckedChange?: (checked: boolean) => void;
}

export const Pin = ({ checked, onCheckedChange, ...restProps }: PinProps) => {
  return <Rate count={1} value={checked ? 1 : 0} onChange={(num) => onCheckedChange?.(!!num)} {...restProps} />;
};
